/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package digitaldreamers.games.ddmonsters.servers.gameserver.network.packets.sending;

import digitaldreamers.libraries.games.servers.networkmanagement.packets.sending.AbSendablePacket;
import digitaldreamers.games.ddmonsters.servers.gameserver.components.basicinfomation.PlayerInformation;
import digitaldreamers.games.ddmonsters.servers.gameserver.configurations.Configuration;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 *
 * @author DaoLe
 */
public class SLoginRequestResponse extends AbSendablePacket {
    private boolean mLoginResult;
    private PlayerInformation mPlayerInformation;
    
    public SLoginRequestResponse(boolean pLoginStatus, PlayerInformation pPlayerInfo) {
        this.mLoginResult = pLoginStatus;
        this.mPlayerInformation = pPlayerInfo;
        mPacketId = Configuration.SENDING_PACKET_ID__LOGIN_REQUEST_RESPONSE;
    }
    
    @Override
    public void writeData(DataOutputStream pDOS) throws IOException {
        pDOS.writeInt(mPacketId);
        pDOS.writeBoolean(mLoginResult);
        if (mLoginResult) {
            pDOS.writeUTF(mPlayerInformation.getNickname());
            pDOS.writeUTF(mPlayerInformation.getEmail());
            pDOS.writeInt(mPlayerInformation.getStarchip());
            pDOS.writeInt(mPlayerInformation.getWin());
            pDOS.writeInt(mPlayerInformation.getLoss());
            pDOS.writeInt(mPlayerInformation.getExperience());
        }
    }
}
